{extend name="public:base"}
{block name='css'}
<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
{/block}
{block name="js"}
<script src="__PUBLIC__/js/plugins/peity/jquery.peity.min.js"></script>
<script src="__PUBLIC__/js/content.min.js?v=1.0.0"></script>
<script type="text/javascript">

    function delAll(self){
        if ($(self).hasClass('ed')) {
            return false;
        }

        layer.confirm('真的要删除吗？删除后将无法找回！', {
            btn: ['确定','取消'] //按钮
        }, function(){
            myRequestRefresh(self, "{:url('delAll')}", $("#delRecord").serialize());
        }, function(){

        });
    }

    function del(self, id){
        if ($(self).hasClass('ed')) {
            return false;
        }

        layer.confirm('真的要删除吗？删除后将无法找回！', {
            btn: ['确定','取消'] //按钮
        }, function(){
            myRequestRefresh(self, "{:url('del')}", {id:id});
        }, function(){

        });
    }

    $(function(){
        //全选的实现
        $(".check-all").click(function(){
            $(".ids").prop("checked", this.checked);
        });
        $(".ids").click(function(){
            var option = $(".ids");
            option.each(function(i){
                if(!this.checked){
                    $(".check-all").prop("checked", false);
                    return false;
                }else{
                    $(".check-all").prop("checked", true);
                }
            });
        });

    });


    function showPeople(self, id, title) {

        layer.open({
            type: 2,
            title: '查看 '+title+' 人员',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: [$(window).width()+'px', $(window).height()+'px'],
            content: "{:url('user/index')}?shop_id="+id
        });
    }
</script>
{/block}
{block name='body'}
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>店铺管理</h5>
                        <a href="{:url('save')}" class="btn btn-sm btn-primary pull-right m-t-n-xs">添加店铺</a>
                    </div>
                    <div class="ibox-content">
						<div class="row">
							<form name="form" action="{:url('index')}" method="get">
                                <div class="col-sm-1 m-b-xs">
                                    <input type="submit" class="btn btn-sm btn-primary btn-sm btn-danger pull-left" onclick="delAll(this);return false;" value="删除"  />
                                </div>

                                <div class="col-sm-4 m-b-xs">
                                    <div class="input-group">
                                        <input type="text" name="keywords" placeholder="店铺名称" value="{:input('keywords', '', 'trim')}" class="input-sm form-control"> <span class="input-group-btn">
                                        <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                                    </div>
                                </div>
							</form>
                        </div>
                        <form name="form" action=""  method="post" id="delRecord">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>
                                        <input class="check-all" type="checkbox" value="">
                                    </th>
                                    <th>名称</th>
                                    <th>联系电话</th>
                                    <th>地址</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
								{foreach name="list" item="li"}
                                <tr>
                                    <td><input type="checkbox" class="ids" value="{$li.id}" name="id[]"></td>
                                    <td>{$li.title}</td>
                                    <td>{$li.tel|default='-'}</td>
                                    <td>{$li.address|default='-'}</td>
                                    <td>
                                        <a href="javascript:;" onclick="showPeople(self, {$li.id}, '{$li.title}');" class="btn btn-info btn-xs"> 查看人员</a>
                                        <a href="{:url('save', ['id'=>$li['id']])}" class="btn btn-success btn-xs edit"><i class="fa fa-edit"></i> 编辑</a>
										<a href="javascript:;" onclick="del(this, {$li.id});" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> 删除</a>
									</td>
                                </tr>
								{/foreach}
                            </tbody>
							<tfoot>
								<tr>
                                    <td colspan="20">
										<div class="zy_page">{$list->render()}</div>
									</td>
                                </tr>
							</tfoot>
                        </table>
                        </form>
                    </div>
                </div>
            </div>
        </div>

    </div>
</body>
{/block}
